home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / LDB171.ARJ / FMUTUAL.CPP < prev    next >
C/C++ Source or Header  |  1992-05-12  |  2KB  |  126 lines

  1. /*
  2.     fmutual.cpp -- Loose Data Binder v 1.7:
  3.         mutually owned and persistence
  4.         "form."
  5.  
  6.     (C) Copyright 1992  John W. Small
  7.     All rights reserved
  8.  
  9.     PSW / Power SoftWare
  10.     P.O. Box 10072
  11.     McLean, Virginia 22102 8072 USA
  12.     (703) 759-3838
  13.  
  14.     Clone this file to speed the development of
  15.     classes derived from a Mutual hierarchy.
  16.  
  17.     replace:    with something like:
  18.  
  19.     CLASS        Mint
  20.     CPTR        MinT
  21.     BASE        Mutual
  22. */
  23.  
  24.  
  25. #ifndef CLASS_HPP
  26. #include "CLASS.hpp"
  27. #endif
  28.  
  29. int CLASS::initData(/* CLASS-declared data
  30.     member initializers */)
  31. {
  32.     // initialize any CLASS-declared data
  33.     // members here
  34.     return 1;  // success
  35. }
  36.  
  37. void CLASS::fput(ostream& os)
  38. {
  39.     BASE::fput(os);
  40. //    os << CLASS-declared data members << Mendm;
  41. //    if (!os)
  42. //        error("unable to store CLASS "
  43. //            "data on stream");
  44. }
  45.  
  46. MutuaL CLASS::fget(istream& is, MutuaL InstancE)
  47. {
  48.     int newed;
  49.     CPTR thiS;
  50.  
  51. //    is >> CLASS-declared data member initializers
  52. //        >> Mnextm;
  53. //    if (!is)  {
  54. //        serror("unable to load CLASS "
  55. //            "data from stream",
  56. //            ID_CLASS);
  57. //        return MutuaL0;
  58. //    }
  59.     if (InstancE)  {
  60.         newed = 0;
  61.         thiS = (CPTR) InstancE;
  62.     }
  63.     else  {
  64.         if ((thiS = new CLASS(initVFTsEtc))
  65.             == CPTR0)  {
  66.             serror("unable to construct "
  67.                 "new CLASS for "
  68.                 "loading",
  69.                 ID_CLASS);
  70.             return MutuaL0;
  71.         }
  72.         newed = 1;
  73.         InstancE = (MutuaL) thiS;
  74.     }
  75.     if (!BASE::fget(is,InstancE))  {
  76.         if (newed)
  77.             delete (voiD) thiS;
  78.         return MutuaL0;
  79.     }
  80.     if (!thiS->initData(/* CLASS-declared data
  81.         member initializers */))  {
  82.         serror("unable to initialize CLASS "
  83.             "from reloaded stream data",
  84.             ID_CLASS);
  85.         if (newed)
  86.             delete (voiD) thiS;
  87.         return MutuaL0;
  88.     }
  89.     return InstancE;
  90. }
  91.  
  92.  
  93. CLASS::CLASS (
  94.         // CLASS-declared data member initializers
  95.         // BASE-declared data member initializers
  96.     ) : BASE (
  97.         // BASE-declared data member initializers
  98.     )
  99.  
  100. {
  101.     (void) initData(
  102.         // CLASS-declared data member initializers
  103.     );
  104. }
  105.  
  106. CLASS::CLASS(CLASS& c) : BASE(c)
  107. {
  108.     // copy initializer constructor
  109. }
  110.  
  111. int CLASS::operator=(Mutual&)
  112. {
  113.     return 0;  // disabled
  114. }
  115.  
  116. MutuaL CLASS::clone()
  117. {
  118.     // invokes copy initializer constructor
  119.     return (MutuaL) new CLASS(*this);
  120. }
  121.  
  122. CLASS::~CLASS()
  123. {
  124.     // ???
  125. }
  126.